<template>
	<view class="center">
		<!-- 用户信息 -->
		<view class="userMessage">
			<!-- 头像 -->
			<view class="avater">
				<image class="avatar-img" :src="userData.avatar"></image>
			</view>
			<!-- 个人信息 -->
			<view class="message" @click="gotorevise">
				<view class="message-top">
					<text class="nickname">
						{{userData.nickname}}
					</text>
					<image class="index-icon Degree-icon" src="https://wlsy.nanjingyunpeng.cn/weixin/image/center5.png"></image>
					<text class="Degree">
						{{userData.school_record}}
					</text>
				</view>
				<image class="index-icon Location-icon jiantou" src="https://wlsy.nanjingyunpeng.cn/weixin/image/center8.png"></image>
				<view class="message-bottom">
					<image v-show="userData.age" class="index-icon" src="https://wlsy.nanjingyunpeng.cn/weixin/image/center6.png"></image>
					<text v-if="userData.age" class="ageText">
						{{userData.age}}岁
					</text>
					<image class="index-icon Location-icon" src="https://wlsy.nanjingyunpeng.cn/weixin/image/center7.png"></image>
					<text class="address">
						{{userData.province}}
					</text>
				</view>

			</view>
		</view>
		<!-- 选项 -->
		<view class="contentList">
			<view class="contentList-inner" @click="gotoHistoryAnswer">
				<image class="contentList-inner-img" src="https://wlsy.nanjingyunpeng.cn/weixin/image/center1.png"></image>
				<view class="contentList-inner-title">
					历史答题
				</view>
			</view>
			<view class="contentList-inner" @click="gotoMQBook">
				<image class="contentList-inner-img" src="https://wlsy.nanjingyunpeng.cn/weixin/image/center2.png">
				</image>
				<view class="contentList-inner-title">
					错题本
				</view>
			</view>
			<view class="contentList-inner" @click="gotoInteger">
				<image class="contentList-inner-img" src="https://wlsy.nanjingyunpeng.cn/weixin/image/center3.png"></image>
				<view class="contentList-inner-title">
					我的积分
				</view>
			</view>
			<view class="contentList-inner" @click="gotoSystemSettings">
				<image class="contentList-inner-img" src="https://wlsy.nanjingyunpeng.cn/weixin/image/center4.png"></image>
				<view class="contentList-inner-title">
					系统设置
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {

		getuserinfo
	} from "../../api/api.js"
	export default {
		data() {
			return {
				userData: {
					avatar: "",
					birthday: "",
					gender: "",
					nickname: "",
					openid: "",
					province: "",
					school_record: "",
					age: ""

				},
			}
		},
		onShow(){
			this.getuserinfo()
		},
		onLoad() {
			this.getuserinfo()
		},
		methods: {
			async getuserinfo() {
				let res = await getuserinfo()
				if (res.code == 1000) {
					// console.log("用户信息center", res)
					this.userData.avatar = res.data.avatar
					this.userData.birthday = res.data.birthday
					this.userData.gender = res.data.gender
					this.userData.age = res.data.age
					this.userData.nickname = res.data.nickname
					this.userData.school_record = res.data.school_record
					this.userData.province = res.data.province
				}
				// console.log("age", this.userData.age)
			},
			// 跳转到历史答题
			gotoHistoryAnswer() {
				uni.navigateTo({
					url: '/pages/center/HistoryAnswers'
				});
			},
			// 跳转到错题本
			gotoMQBook() {
				uni.navigateTo({
					url: `/pages/problem/WQBook?type=${"center"}`
				});
			},
			// 跳转到我的积分
			gotoInteger() {
				uni.navigateTo({
					url: '/pages/center/Integral'
				});
			},
			//跳转到系统设置
			gotoSystemSettings() {
				uni.navigateTo({
					url: '/pages/centerlist/SystemSettings'
				});
			},
			//跳转到资料修改
			gotorevise() {
				uni.navigateTo({
					url: '/pages/centerlist/revise'
				});
			},

		}
	}
</script>

<style scoped lang="scss">
	.center {
		min-height: 100%;
		background-color: #EEF7FE;
		position: relative;

		.jiantou {
			position: absolute;
			top: 80rpx;
			right: 30rpx;
		}
	}

	.userMessage {
		width: 100%;
		height: 300rpx;
		background: linear-gradient(1deg, #688EFA 0%, #466EE7 100%);
		border-radius: 0px 0px 50rpx 50rpx;
		opacity: 1;
		box-sizing: border-box;
		padding-left: 40rpx;
		padding-top: 50rpx;
		display: flex;

	}

	.avater {
		width: 140rpx;
		height: 140rpx;
		border-radius: 140rpx;
	}

	.avatar-img {
		width: 100%;
		height: 100%;
		border-radius: 140rpx;
	}

	.contentList {
		width: 690rpx;
		height: 210rpx;
		margin-left: 30rpx;
		background: #FFFFFF;
		box-shadow: 0px 1px 4rpx 0px rgba(51, 51, 51, 0.05);
		border-radius: 30rpx 30rpx 30rpx 30rpx;
		opacity: 1;
		background-color: #FFFFFF;
		margin-top: -60rpx;
		display: flex;
		justify-content: space-around;
		padding-top: 40rpx;
		box-sizing: border-box;
	}

	.contentList-inner {
		text-align: center;
		display: flex;
		justify-content: space-between;
		flex-direction: column;
		align-items: center;
		padding-bottom: 50rpx;
		box-sizing: border-box;
	}

	.contentList-inner-img {
		width: 80rpx;
		height: 80rpx;
	}

	.contentList-inner-title {
		font-size: 14px;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		line-height: 16px;
	}

	.message {
		display: flex;
		flex-direction: column;
		font-size: 14px;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 16px;
		margin-left: 30rpx;
		width: 500rpx;
		// background-color: pink;
		height: 140rpx;

		.message-top {
			.nickname {
				width: 120rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			display: flex;
			align-items: center;
		}

	}

	.message-bottom {
		display: flex;
		align-items: center;
		margin-top: 20rpx;

		.ageText {
			width: 70rpx;
			height: 30rpx;
			display: inline-block;
		}

		.address {
			width: 186rpx;
			height: 33rpx;
			font-size: 28rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 33rpx;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;

		}

	}

	.index-icon {
		width: 40rpx;
		height: 40rpx;
	}

	.Degree-icon {
		margin-left: 63rpx;
		margin-right: 10rpx;
	}

	.Location-icon {
		margin-left: 75rpx;
		margin-right: 10rpx;
	}
</style>
